<?php
namespace app\admin\controller;

use app\common\controller\AdminBase;
use think\Config;
use think\Db;

class signin extends AdminBase
{

    protected function _initialize()
    {
        parent::_initialize();
    }

    /**
     * 管理
     * @param string $keyword
     * @param int    $page
     * @return mixed
     */
    public function index($keyword_name = '',$keyword_phone = '',$keyword_coupon = '', $page = 1)
    {
        $signin = Db('signin')->order('id')->find();

        return $this->fetch('index', ['signin' => $signin]);
    }

    /**
     * 更新
     * @param $id
     */
    public function update($id)
    {
        if ($this->request->isPost()) {
            $data            = $this->request->post();
            $validate_result = $this->validate($data, 'signin');

            if ($validate_result !== true) {
                $this->error($validate_result);
            } else {
                if (Db('signin')->where('id',$id)->update($data) !== false) {
                    $this->success('设置成功');
                } else {
                    $this->error('设置失败');
                }
            }
        }
    }

}